/**
 * Created by shc@lierda.com on 2017/2/22.
 */
var React = require('react');
var IconText = require('../components/IconText');
var ajax = require('../tools/ajax');

module.exports = React.createClass({
    getInitialState: function (){
        return {
            theme:"Default",
            slist:[]
        }
    },
    componentDidMount: function () {
        if(this.props.theme){
            this.setState({theme:this.props.theme});
        }
    },
    action:function(e){
        var userId = localStorage.getItem("userId");
        if(userId){
            var action = e.currentTarget.getAttribute("action");
            var shopId = localStorage.getItem("shopId");
            localStorage.setItem("judgeShop",shopId);
            location.href = action;
        }else{
            location.href = "#login";
        }
    },
    render: function () {
        var p = this;
        var  slist = this.state.slist.map(function(obj){
            return(
                <div key={obj.id} className={p.state.theme+"_home_Brand"} onClick={p.action} action={obj.action}>
                    <div>
                        <img src={obj.icon} style={{width:"2.1rem",height:"2.1rem"}}/>
                        <div className="home-title-c">{obj.chinesetitle}</div>
                    </div>
                </div>
            )
        });

        return (
            <div className="home_brand" style={{paddingBottom:"0.5rem"}}>
                {slist}
            </div>
        )
    }
});
